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

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

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

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

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

d.t = i
i.y = m
i.r = b
m.q = b
m.w = b
m.r = b
m.y = i
b.o = m
b.s = m
f.o = m
f.s = m
j.t = i
assert m.w.o.y.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

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

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

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

d.t = i
i.y = m
i.r = b
m.q = b
m.w = b
m.r = b
m.y = i
b.o = m
b.s = m
f.o = m
f.s = m
j.t = i
assert m.w.o.y.txt == "i"