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

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

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

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

j.u = c
h.v = b
h.x = j
m.r = k
c.u = j
k.v = b
k.x = c
e.r = k
l.r = k
b.r = k
assert j.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.txt = txt

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

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

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

j.u = c
h.v = b
h.x = j
m.r = k
c.u = j
k.v = b
k.x = c
e.r = k
l.r = k
b.r = k
assert j.u.u.u.txt == "c"