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

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

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

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

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

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

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

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

k.q = l
k.u = b
c.p = b
c.q = b
c.x = l
e.q = l
e.x = k
b.p = c
b.q = c
b.x = l
l.q = k
l.u = c
assert k.q.u.p.q.txt == "c"