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

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

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

e = A("e")
b = B("b")
j = C("j")
k = A("k")

e.o = b
b.y = j
b.v = e
j.p = b
j.o = e
k.o = b
assert b.v.o.v.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

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

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

e = A("e")
b = B("b")
j = C("j")
k = A("k")

e.o = b
b.y = j
b.v = e
j.p = b
j.o = e
k.o = b
assert b.v.o.v.o.txt == "b"