The present invention relates to a cyclic aminomethyl pyrimidine derivative and a pharmacologically acceptable salt thereof which have a highly selective action on a dopamine D4 receptor and are useful as a therapeutic agent for attention deficit hyperactivity disorder, etc. Specifically, the present invention relates to a compound represented by formula (1) or a pharmacologically acceptable salt thereof. [In the formula, n and m are each independently 1 or 2, W1, W3 and W4 are each independently a single bond or a C1-4 alkylene group which may be substituted, W2 is a C1-4 alkylene group which may be substituted, R1 and R2 are each independently a hydrogen atom, etc., R3 is a hydrogen atom, halogen atom, etc., X1 and X2 are each independently a single bond, oxygen atom, etc., ring Q1 is a 5 to 10-membered heteroaryl group which may be substituted, etc., and ring Q2 is a 6-membered heteroaryl group which may be substituted, etc.]Cette invention concerne un dérivé d'aminométhylpyrimidine cyclique et un sel pharmacologiquement acceptable de celui-ci qui ont une action très sélective sur un récepteur de dopamine D4 et sont utiles à titre d'agent thérapeutique pour le trouble du déficit de l'attention avec hyperactivité, etc. Plus spécifiquement, cette invention concerne un composé représenté par la formule (1) ou un sel pharmacologiquement acceptable de celui-ci. [Dans la formule, n et m sont chacun indépendamment 1 ou 2, W1, W3 et W4sont chacun indépendamment une liaison simple ou un groupe alkylène C1-4 qui peut être substitué, W2un groupe alkylène C1-4 qui peut être substitué, R1 et R2 sont chacun indépendamment un atome d'hydrogène, etc., R3 est un atome d'hydrogène, un atome d'halogène, etc., X1 et X2 sont chacun indépendamment une liaison simple, un atome d'oxygène, etc., le cycle Q1 est un groupe hétéroaryle ayant de 5 à 10 chaînons qui peut être substitué, etc., et le cycle Q2 est un groupe hétéroaryle ayant 6 chaînons qui peut être substitué, etc.]本発明は、ドパミンD4受容