class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.t: E = None
        self.txt = txt

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.u: E = None
        self.txt = txt

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

j.z = m
j.t = n
l.y = m
l.x = m
l.u = m
l.w = h
l.v = h
l.q = n
c.z = j
c.o = j
c.w = l
c.q = h
m.q = h
m.z = h
n.p = m
h.u = n
assert c.w.q.p.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.t: E = None
        self.txt = txt

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.u: E = None
        self.txt = txt

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

j.z = m
j.t = n
l.y = m
l.x = m
l.u = m
l.w = h
l.v = h
l.q = n
c.z = j
c.o = j
c.w = l
c.q = h
m.q = h
m.z = h
n.p = m
h.u = n
assert c.w.q.p.z.txt == "h"