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

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

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

class D:
    def __init__(self, txt: str):
        self.y: D = None
        self.r: D = None
        self.txt = txt

e = A("e")
g = B("g")
j = C("j")
k = D("k")
f = A("f")
n = D("n")
i = A("i")

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

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

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

class D:
    def __init__(self, txt: str):
        self.y: D = None
        self.r: D = None
        self.txt = txt

e = A("e")
g = B("g")
j = C("j")
k = D("k")
f = A("f")
n = D("n")
i = A("i")

e.t = g
e.x = g
g.o = n
j.u = f
k.y = n
k.r = n
f.t = g
f.x = g
n.y = k
n.r = k
i.t = g
i.x = g
assert g.o.r.r.r.r.txt == "n"