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

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

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

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

m = A("m")
k = B("k")
e = C("e")
l = D("l")

m.t = e
k.q = e
k.y = e
k.w = e
k.s = l
e.y = m
l.y = k
l.s = k
l.r = m
assert l.r.t.y.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

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

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

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

m = A("m")
k = B("k")
e = C("e")
l = D("l")

m.t = e
k.q = e
k.y = e
k.w = e
k.s = l
e.y = m
l.y = k
l.s = k
l.r = m
assert l.r.t.y.t.txt == "e"