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

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

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

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

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

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

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

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

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

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

b.t = i
b.y = j
c.s = i
m.y = j
h.y = i
i.y = j
j.s = i
assert i.y.s.y.s.y.s.txt == "i"