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

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

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

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

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

b.t = i
j.r = l
m.x = l
m.r = l
l.s = b
l.y = m
l.x = j
l.t = j
i.x = l
i.r = l
assert m.x.y.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

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

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

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

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

b.t = i
j.r = l
m.x = l
m.r = l
l.s = b
l.y = m
l.x = j
l.t = j
i.x = l
i.r = l
assert m.x.y.x.x.txt == "j"