class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.o: B = None
        self.q: F = None
        self.v: B = None
        self.r: F = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.y: A = None
        self.v: A = None
        self.r: E = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.y: B = None
        self.x: D = None
        self.q: D = None
        self.o: F = None
        self.w: D = None
        self.z: B = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.v: D = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.p: B = None
        self.r: B = None
        self.v: A = None
        self.z: A = None
        self.txt = txt

n = A("n")
m = B("m")
l = C("l")
j = D("j")
h = E("h")
g = F("g")

n.p = l
n.o = m
n.v = m
n.q = g
n.r = g
m.y = n
m.v = n
m.r = h
l.y = m
l.z = m
l.x = j
l.q = j
l.w = j
l.o = g
j.o = m
h.v = j
g.p = m
g.r = m
g.v = n
g.z = n
assert n.r.p.r.v.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.o: B = None
        self.q: F = None
        self.v: B = None
        self.r: F = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.y: A = None
        self.v: A = None
        self.r: E = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.y: B = None
        self.x: D = None
        self.q: D = None
        self.o: F = None
        self.w: D = None
        self.z: B = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.v: D = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.p: B = None
        self.r: B = None
        self.v: A = None
        self.z: A = None
        self.txt = txt

n = A("n")
m = B("m")
l = C("l")
j = D("j")
h = E("h")
g = F("g")

n.p = l
n.o = m
n.v = m
n.q = g
n.r = g
m.y = n
m.v = n
m.r = h
l.y = m
l.z = m
l.x = j
l.q = j
l.w = j
l.o = g
j.o = m
h.v = j
g.p = m
g.r = m
g.v = n
g.z = n
assert n.r.p.r.v.txt == "j"