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

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

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

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

f = A("f")
i = B("i")
d = C("d")
g = D("g")
c = A("c")
k = C("k")
j = C("j")
b = A("b")
n = B("n")

f.o = b
f.r = c
f.t = n
i.o = d
d.t = i
g.u = k
c.o = b
c.r = f
c.t = n
k.t = i
j.t = n
b.o = f
b.r = f
b.t = n
n.o = k
assert g.u.t.o.t.o.t.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.r: A = None
        self.t: B = None
        self.txt = txt

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

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

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

f = A("f")
i = B("i")
d = C("d")
g = D("g")
c = A("c")
k = C("k")
j = C("j")
b = A("b")
n = B("n")

f.o = b
f.r = c
f.t = n
i.o = d
d.t = i
g.u = k
c.o = b
c.r = f
c.t = n
k.t = i
j.t = n
b.o = f
b.r = f
b.t = n
n.o = k
assert g.u.t.o.t.o.t.txt == "i"