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

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

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

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

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

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

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

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

l.q = e
k.w = e
k.o = j
e.y = k
e.r = l
j.y = k
j.r = l
c.q = j
b.q = e
assert e.r.q.r.q.r.q.txt == "e"