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

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

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

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

c = A("c")
m = B("m")
a = C("a")
k = D("k")
b = D("b")
h = B("h")

c.s = a
c.r = a
c.w = a
c.u = h
m.x = a
a.s = b
k.t = a
b.t = a
h.x = a
assert a.s.t.s.t.s.t.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.r: C = None
        self.u: B = None
        self.w: C = None
        self.txt = txt

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

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

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

c = A("c")
m = B("m")
a = C("a")
k = D("k")
b = D("b")
h = B("h")

c.s = a
c.r = a
c.w = a
c.u = h
m.x = a
a.s = b
k.t = a
b.t = a
h.x = a
assert a.s.t.s.t.s.t.txt == "a"