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

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

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

class D:
    def __init__(self, txt: str):
        self.t: A = None
        self.q: A = None
        self.p: A = None
        self.txt = txt

k = A("k")
d = B("d")
l = C("l")
f = D("f")
e = A("e")
b = B("b")

k.r = e
k.w = f
k.o = d
d.x = f
d.z = l
l.u = d
l.r = f
l.p = f
f.t = e
f.q = k
f.p = k
e.r = k
e.w = f
e.o = d
b.x = f
b.z = l
assert b.z.p.t.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.w: D = None
        self.o: B = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.t: A = None
        self.q: A = None
        self.p: A = None
        self.txt = txt

k = A("k")
d = B("d")
l = C("l")
f = D("f")
e = A("e")
b = B("b")

k.r = e
k.w = f
k.o = d
d.x = f
d.z = l
l.u = d
l.r = f
l.p = f
f.t = e
f.q = k
f.p = k
e.r = k
e.w = f
e.o = d
b.x = f
b.z = l
assert b.z.p.t.txt == "e"