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

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

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

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

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

k = A("k")
j = B("j")
d = C("d")
e = D("e")
b = E("b")
c = E("c")
h = C("h")

k.r = j
k.t = j
k.u = h
k.p = c
j.r = k
d.x = k
e.y = c
e.z = c
e.u = k
e.q = h
e.p = j
b.r = k
c.r = k
h.x = k
assert b.r.p.r.p.r.u.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.u: C = None
        self.t: B = None
        self.p: E = None
        self.txt = txt

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

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

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

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

k = A("k")
j = B("j")
d = C("d")
e = D("e")
b = E("b")
c = E("c")
h = C("h")

k.r = j
k.t = j
k.u = h
k.p = c
j.r = k
d.x = k
e.y = c
e.z = c
e.u = k
e.q = h
e.p = j
b.r = k
c.r = k
h.x = k
assert b.r.p.r.p.r.u.txt == "h"