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

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

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

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

f = A("f")
j = B("j")
c = C("c")
l = D("l")
h = C("h")
a = D("a")

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

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

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

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

f = A("f")
j = B("j")
c = C("c")
l = D("l")
h = C("h")
a = D("a")

f.z = l
f.y = j
j.s = l
c.t = h
c.w = h
c.x = a
c.s = l
l.s = f
h.t = c
h.w = c
h.x = l
h.s = a
a.s = f
assert c.x.s.y.s.s.txt == "f"