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

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

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

e = A("e")
k = B("k")
l = C("l")
b = C("b")
i = B("i")
c = B("c")
f = B("f")

e.y = k
k.p = l
k.x = e
k.o = b
l.v = e
l.q = b
b.v = e
b.q = l
i.p = l
i.o = l
i.x = e
c.p = l
c.o = l
c.x = e
f.p = b
f.o = b
f.x = e
assert k.p.v.y.p.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

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

e = A("e")
k = B("k")
l = C("l")
b = C("b")
i = B("i")
c = B("c")
f = B("f")

e.y = k
k.p = l
k.x = e
k.o = b
l.v = e
l.q = b
b.v = e
b.q = l
i.p = l
i.o = l
i.x = e
c.p = l
c.o = l
c.x = e
f.p = b
f.o = b
f.x = e
assert k.p.v.y.p.txt == "l"