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

class B:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.z: C = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.o: A = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

m = A("m")
h = B("h")
f = C("f")
d = D("d")
b = E("b")
k = F("k")
j = E("j")
c = A("c")
g = A("g")

m.q = h
m.y = h
m.v = j
m.x = k
h.u = f
f.x = c
f.q = c
f.y = h
f.w = k
f.v = d
f.z = d
d.z = f
b.o = g
k.r = f
j.o = g
c.q = h
c.y = h
c.v = b
c.x = k
g.q = h
g.y = h
g.v = j
g.x = k
assert g.x.r.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.y: B = None
        self.v: E = None
        self.x: F = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.z: C = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.o: A = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

m = A("m")
h = B("h")
f = C("f")
d = D("d")
b = E("b")
k = F("k")
j = E("j")
c = A("c")
g = A("g")

m.q = h
m.y = h
m.v = j
m.x = k
h.u = f
f.x = c
f.q = c
f.y = h
f.w = k
f.v = d
f.z = d
d.z = f
b.o = g
k.r = f
j.o = g
c.q = h
c.y = h
c.v = b
c.x = k
g.q = h
g.y = h
g.v = j
g.x = k
assert g.x.r.q.txt == "c"