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

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

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

j = A("j")
l = B("l")
h = C("h")
d = C("d")
a = B("a")

j.t = a
l.x = d
l.s = d
h.w = d
d.w = h
a.x = h
a.s = d
assert h.w.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

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

j = A("j")
l = B("l")
h = C("h")
d = C("d")
a = B("a")

j.t = a
l.x = d
l.s = d
h.w = d
d.w = h
a.x = h
a.s = d
assert h.w.w.w.w.txt == "h"