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

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

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

k = A("k")
n = B("n")
l = C("l")
g = B("g")
h = A("h")
c = B("c")
f = A("f")
a = B("a")

k.y = h
n.u = l
l.x = k
l.s = k
g.u = l
h.y = k
c.u = l
f.y = k
a.u = l
assert g.u.s.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

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

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

k = A("k")
n = B("n")
l = C("l")
g = B("g")
h = A("h")
c = B("c")
f = A("f")
a = B("a")

k.y = h
n.u = l
l.x = k
l.s = k
g.u = l
h.y = k
c.u = l
f.y = k
a.u = l
assert g.u.s.y.y.y.txt == "h"