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

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

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

h = A("h")
c = B("c")
b = C("b")
d = B("d")
j = B("j")
g = A("g")
e = B("e")
i = B("i")
k = C("k")
l = A("l")

h.o = k
h.q = g
c.p = d
b.s = k
b.x = j
b.q = h
d.p = e
j.p = i
g.o = k
g.q = h
e.p = c
i.p = d
k.s = b
k.x = j
k.q = l
l.o = b
l.q = h
assert c.p.p.p.p.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.q: A = None
        self.txt = txt

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

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

h = A("h")
c = B("c")
b = C("b")
d = B("d")
j = B("j")
g = A("g")
e = B("e")
i = B("i")
k = C("k")
l = A("l")

h.o = k
h.q = g
c.p = d
b.s = k
b.x = j
b.q = h
d.p = e
j.p = i
g.o = k
g.q = h
e.p = c
i.p = d
k.s = b
k.x = j
k.q = l
l.o = b
l.q = h
assert c.p.p.p.p.p.p.p.txt == "d"