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

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

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

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

b.r = k
c.y = b
c.o = b
c.u = b
j.q = c
k.q = h
h.y = b
h.o = b
h.u = b
assert b.r.q.o.r.q.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

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

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

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

b.r = k
c.y = b
c.o = b
c.u = b
j.q = c
k.q = h
h.y = b
h.o = b
h.u = b
assert b.r.q.o.r.q.txt == "h"