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

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

class C:
    def __init__(self, txt: str):
        self.p: B = None
        self.z: A = None
        self.txt = txt

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

e = A("e")
b = B("b")
f = C("f")
k = D("k")
a = A("a")
c = D("c")

e.u = b
b.r = e
b.p = f
b.s = f
f.p = b
f.z = a
k.o = b
k.p = b
a.u = b
c.o = b
c.p = b
assert b.r.u.p.p.r.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.p: B = None
        self.z: A = None
        self.txt = txt

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

e = A("e")
b = B("b")
f = C("f")
k = D("k")
a = A("a")
c = D("c")

e.u = b
b.r = e
b.p = f
b.s = f
f.p = b
f.z = a
k.o = b
k.p = b
a.u = b
c.o = b
c.p = b
assert b.r.u.p.p.r.txt == "e"