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

class B:
    def __init__(self, txt: str):
        self.u: D = None
        self.o: C = None
        self.p: A = None
        self.q: D = None
        self.txt = txt

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

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

i = A("i")
e = B("e")
a = C("a")
m = D("m")
d = A("d")
f = A("f")

i.o = a
i.t = f
e.u = m
e.q = m
e.o = a
e.p = i
a.u = i
a.o = e
m.u = f
m.t = a
m.q = a
m.p = e
d.o = a
d.t = i
f.o = a
f.t = i
assert a.u.t.t.t.t.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.t: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: D = None
        self.o: C = None
        self.p: A = None
        self.q: D = None
        self.txt = txt

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

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

i = A("i")
e = B("e")
a = C("a")
m = D("m")
d = A("d")
f = A("f")

i.o = a
i.t = f
e.u = m
e.q = m
e.o = a
e.p = i
a.u = i
a.o = e
m.u = f
m.t = a
m.q = a
m.p = e
d.o = a
d.t = i
f.o = a
f.t = i
assert a.u.t.t.t.t.o.txt == "a"