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

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

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

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

d = A("d")
m = B("m")
i = C("i")
b = D("b")
k = C("k")

d.t = i
d.y = i
d.p = m
d.x = k
m.s = k
m.v = k
m.p = k
m.q = i
i.r = d
b.q = m
b.r = d
k.r = d
assert b.q.q.r.x.r.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.y: C = None
        self.p: B = None
        self.x: C = None
        self.txt = txt

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

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

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

d = A("d")
m = B("m")
i = C("i")
b = D("b")
k = C("k")

d.t = i
d.y = i
d.p = m
d.x = k
m.s = k
m.v = k
m.p = k
m.q = i
i.r = d
b.q = m
b.r = d
k.r = d
assert b.q.q.r.x.r.txt == "d"