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

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

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

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

i = A("i")
f = B("f")
h = C("h")
b = D("b")
j = D("j")
m = C("m")

i.x = f
i.w = f
i.z = h
i.t = m
f.p = m
f.r = m
f.q = h
h.q = m
h.p = m
b.x = f
j.x = f
m.q = h
m.p = h
assert m.q.p.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.z: C = None
        self.t: C = None
        self.w: B = None
        self.txt = txt

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

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

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

i = A("i")
f = B("f")
h = C("h")
b = D("b")
j = D("j")
m = C("m")

i.x = f
i.w = f
i.z = h
i.t = m
f.p = m
f.r = m
f.q = h
h.q = m
h.p = m
b.x = f
j.x = f
m.q = h
m.p = h
assert m.q.p.q.q.txt == "m"