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

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

class C:
    def __init__(self, txt: str):
        self.w: A = None
        self.o: D = None
        self.txt = txt

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

i = A("i")
f = B("f")
j = C("j")
m = D("m")
d = B("d")
a = B("a")
h = D("h")
b = A("b")

i.t = b
f.t = j
f.q = a
j.w = b
j.o = m
m.z = a
d.t = j
d.q = a
a.t = j
a.q = d
h.z = d
b.t = i
assert m.z.q.q.t.o.z.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.w: A = None
        self.o: D = None
        self.txt = txt

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

i = A("i")
f = B("f")
j = C("j")
m = D("m")
d = B("d")
a = B("a")
h = D("h")
b = A("b")

i.t = b
f.t = j
f.q = a
j.w = b
j.o = m
m.z = a
d.t = j
d.q = a
a.t = j
a.q = d
h.z = d
b.t = i
assert m.z.q.q.t.o.z.txt == "a"