class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.u: A = None
        self.txt = txt

i = A("i")
f = B("f")
k = C("k")
d = D("d")
g = D("g")
l = C("l")
e = A("e")
n = C("n")
a = C("a")
h = D("h")

i.y = a
f.q = a
f.u = k
f.t = k
f.z = h
k.u = f
d.u = i
g.u = i
l.u = f
e.y = k
n.u = f
a.u = f
h.u = i
assert i.y.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.u: A = None
        self.txt = txt

i = A("i")
f = B("f")
k = C("k")
d = D("d")
g = D("g")
l = C("l")
e = A("e")
n = C("n")
a = C("a")
h = D("h")

i.y = a
f.q = a
f.u = k
f.t = k
f.z = h
k.u = f
d.u = i
g.u = i
l.u = f
e.y = k
n.u = f
a.u = f
h.u = i
assert i.y.u.u.txt == "k"