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

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

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

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

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

d = A("d")
c = B("c")
f = C("f")
b = D("b")
g = E("g")
a = B("a")
i = B("i")
j = E("j")

d.o = j
c.r = i
f.p = d
f.s = j
f.y = b
b.q = a
g.q = f
g.o = d
g.z = j
g.u = b
a.r = i
i.r = a
j.q = f
j.o = d
j.z = g
j.u = b
assert i.r.r.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.o: E = None
        self.txt = txt

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

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

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

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

d = A("d")
c = B("c")
f = C("f")
b = D("b")
g = E("g")
a = B("a")
i = B("i")
j = E("j")

d.o = j
c.r = i
f.p = d
f.s = j
f.y = b
b.q = a
g.q = f
g.o = d
g.z = j
g.u = b
a.r = i
i.r = a
j.q = f
j.o = d
j.z = g
j.u = b
assert i.r.r.r.r.r.txt == "a"