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

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

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

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

f = A("f")
h = B("h")
k = C("k")
n = D("n")
a = D("a")
d = B("d")
c = A("c")

f.s = h
f.y = h
h.x = d
h.o = d
k.z = c
k.u = n
k.w = n
k.t = a
n.x = k
a.x = k
d.x = h
d.o = h
c.s = h
c.y = d
assert c.s.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.y: B = None
        self.txt = txt

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

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

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

f = A("f")
h = B("h")
k = C("k")
n = D("n")
a = D("a")
d = B("d")
c = A("c")

f.s = h
f.y = h
h.x = d
h.o = d
k.z = c
k.u = n
k.w = n
k.t = a
n.x = k
a.x = k
d.x = h
d.o = h
c.s = h
c.y = d
assert c.s.x.x.txt == "h"