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

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

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

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

b = A("b")
i = B("i")
k = C("k")
f = D("f")
g = A("g")
l = D("l")
n = B("n")
c = A("c")

b.z = k
b.o = c
i.y = f
i.s = f
k.t = n
f.x = k
f.s = b
g.z = k
g.o = c
l.x = k
l.s = g
n.y = f
n.s = f
c.z = k
c.o = b
assert g.o.o.o.o.o.o.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.o: A = None
        self.txt = txt

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

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

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

b = A("b")
i = B("i")
k = C("k")
f = D("f")
g = A("g")
l = D("l")
n = B("n")
c = A("c")

b.z = k
b.o = c
i.y = f
i.s = f
k.t = n
f.x = k
f.s = b
g.z = k
g.o = c
l.x = k
l.s = g
n.y = f
n.s = f
c.z = k
c.o = b
assert g.o.o.o.o.o.o.z.txt == "k"