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

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

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

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

m = A("m")
e = B("e")
h = C("h")
d = D("d")
c = D("c")
j = C("j")

m.t = e
m.x = e
m.q = h
m.y = d
e.t = m
h.s = j
d.s = c
d.y = e
d.r = j
d.p = j
c.s = d
c.y = e
c.r = h
c.p = h
j.s = h
assert h.s.s.s.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.x: B = None
        self.q: C = None
        self.y: D = None
        self.txt = txt

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

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

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

m = A("m")
e = B("e")
h = C("h")
d = D("d")
c = D("c")
j = C("j")

m.t = e
m.x = e
m.q = h
m.y = d
e.t = m
h.s = j
d.s = c
d.y = e
d.r = j
d.p = j
c.s = d
c.y = e
c.r = h
c.p = h
j.s = h
assert h.s.s.s.s.s.s.txt == "h"