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

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

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

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

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

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

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

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

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

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

c.t = h
c.y = k
k.o = n
n.o = h
n.s = h
b.z = i
b.p = a
g.o = n
a.o = c
a.s = c
i.o = f
f.o = h
f.s = c
h.t = c
h.y = i
d.z = k
d.p = a
assert h.y.o.s.y.o.s.t.txt == "c"