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

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

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

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

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

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

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

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

b.q = k
b.p = k
b.x = e
c.r = b
c.u = k
c.q = k
d.x = i
d.v = i
i.x = d
i.v = d
k.r = e
k.u = c
k.q = c
e.q = c
e.x = b
e.p = k
assert c.r.p.u.r.p.txt == "k"