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

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

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

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

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

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

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

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

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

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

d.t = b
d.u = k
d.w = k
d.p = a
b.x = f
b.r = e
b.q = d
b.y = d
a.s = b
f.s = b
k.s = b
e.t = b
e.u = f
e.w = f
e.p = a
assert e.p.s.q.txt == "d"