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

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

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

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

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

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

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

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

j.y = c
n.w = e
n.q = e
k.v = b
k.o = c
e.w = n
e.q = n
h.v = b
h.o = j
b.v = h
b.o = j
c.y = j
assert b.o.y.y.y.txt == "c"