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

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

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

f = A("f")
g = B("g")
k = C("k")
b = B("b")
c = C("c")
j = A("j")
d = B("d")
h = B("h")

f.y = j
f.t = c
g.q = c
g.t = f
g.v = b
k.p = c
k.q = c
b.q = k
b.t = f
b.v = h
c.p = k
c.q = k
j.y = f
j.t = c
d.q = k
d.t = f
d.v = h
h.q = c
h.t = j
h.v = d
assert c.q.p.p.p.p.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.t: C = None
        self.txt = txt

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

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

f = A("f")
g = B("g")
k = C("k")
b = B("b")
c = C("c")
j = A("j")
d = B("d")
h = B("h")

f.y = j
f.t = c
g.q = c
g.t = f
g.v = b
k.p = c
k.q = c
b.q = k
b.t = f
b.v = h
c.p = k
c.q = k
j.y = f
j.t = c
d.q = k
d.t = f
d.v = h
h.q = c
h.t = j
h.v = d
assert c.q.p.p.p.p.p.p.p.txt == "c"