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

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

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

l = A("l")
b = B("b")
k = C("k")
g = C("g")

l.p = k
l.o = b
b.x = k
b.o = l
k.v = g
g.v = k
assert g.v.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.o: B = None
        self.txt = txt

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

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

l = A("l")
b = B("b")
k = C("k")
g = C("g")

l.p = k
l.o = b
b.x = k
b.o = l
k.v = g
g.v = k
assert g.v.v.v.v.txt == "g"