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

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

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

l = A("l")
h = B("h")
c = C("c")
g = C("g")
m = B("m")
e = A("e")

l.v = h
l.q = e
h.p = g
h.s = g
c.u = g
g.u = c
m.p = g
m.s = g
e.v = m
e.q = l
assert c.u.u.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.q: A = None
        self.txt = txt

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

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

l = A("l")
h = B("h")
c = C("c")
g = C("g")
m = B("m")
e = A("e")

l.v = h
l.q = e
h.p = g
h.s = g
c.u = g
g.u = c
m.p = g
m.s = g
e.v = m
e.q = l
assert c.u.u.u.u.u.u.txt == "c"