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

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

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

i = A("i")
m = B("m")
l = C("l")
g = B("g")
a = A("a")
n = C("n")
b = C("b")
j = A("j")

i.p = a
m.v = n
l.q = g
l.t = j
g.v = b
a.p = i
n.q = m
n.t = a
b.q = g
b.t = i
j.p = a
assert i.p.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.txt = txt

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

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

i = A("i")
m = B("m")
l = C("l")
g = B("g")
a = A("a")
n = C("n")
b = C("b")
j = A("j")

i.p = a
m.v = n
l.q = g
l.t = j
g.v = b
a.p = i
n.q = m
n.t = a
b.q = g
b.t = i
j.p = a
assert i.p.p.p.p.txt == "i"