class A:
    def __init__(self, txt: str):
        self.q: E = None
        self.o: C = None
        self.p: E = None
        self.r: E = None
        self.u: C = 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.x: B = None
        self.txt = txt

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

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

b = A("b")
f = B("f")
j = C("j")
i = D("i")
h = E("h")
n = B("n")
c = B("c")

b.q = h
b.p = h
b.r = h
b.o = j
b.u = j
f.r = c
j.x = c
i.s = h
i.z = n
i.p = f
h.s = i
n.r = f
c.r = n
assert f.r.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.q: E = None
        self.o: C = None
        self.p: E = None
        self.r: E = None
        self.u: C = 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.x: B = None
        self.txt = txt

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

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

b = A("b")
f = B("f")
j = C("j")
i = D("i")
h = E("h")
n = B("n")
c = B("c")

b.q = h
b.p = h
b.r = h
b.o = j
b.u = j
f.r = c
j.x = c
i.s = h
i.z = n
i.p = f
h.s = i
n.r = f
c.r = n
assert f.r.r.r.r.txt == "c"