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

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

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

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

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

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

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

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

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

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

l.q = h
l.t = m
l.u = j
j.s = m
j.w = h
e.x = l
e.t = m
e.p = m
h.x = e
m.x = l
m.t = e
m.p = e
assert m.x.t.t.x.t.txt == "m"