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

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

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

k = A("k")
d = B("d")
c = C("c")
m = A("m")

k.y = d
k.q = d
k.o = m
d.y = c
d.o = c
c.x = k
c.r = d
m.y = d
m.q = d
m.o = k
assert k.y.o.x.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.o: A = None
        self.q: B = None
        self.txt = txt

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

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

k = A("k")
d = B("d")
c = C("c")
m = A("m")

k.y = d
k.q = d
k.o = m
d.y = c
d.o = c
c.x = k
c.r = d
m.y = d
m.q = d
m.o = k
assert k.y.o.x.txt == "k"