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

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

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

k = A("k")
c = B("c")
m = C("m")
g = C("g")
e = C("e")

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

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

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

k = A("k")
c = B("c")
m = C("m")
g = C("g")
e = C("e")

k.p = c
c.q = k
c.v = k
c.u = k
m.q = k
g.q = k
e.q = k
assert g.q.p.u.p.u.txt == "k"