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

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

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

b = A("b")
j = B("j")
e = C("e")
a = C("a")
k = A("k")
h = A("h")
f = B("f")

b.r = e
b.q = h
j.u = f
j.q = f
j.s = h
e.q = j
e.z = a
e.r = a
a.q = f
a.z = e
a.r = e
k.r = a
k.q = h
h.r = e
h.q = k
f.u = j
f.q = j
f.s = b
assert j.q.s.r.q.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.q: A = None
        self.txt = txt

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

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

b = A("b")
j = B("j")
e = C("e")
a = C("a")
k = A("k")
h = A("h")
f = B("f")

b.r = e
b.q = h
j.u = f
j.q = f
j.s = h
e.q = j
e.z = a
e.r = a
a.q = f
a.z = e
a.r = e
k.r = a
k.q = h
h.r = e
h.q = k
f.u = j
f.q = j
f.s = b
assert j.q.s.r.q.txt == "j"