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

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

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

b = A("b")
c = B("c")
l = C("l")
f = B("f")
g = A("g")
j = C("j")
h = B("h")
i = B("i")

b.q = g
b.y = g
c.p = j
c.w = j
c.v = g
l.p = i
f.p = j
f.w = j
f.v = b
g.q = b
g.y = b
j.p = i
h.p = j
h.w = l
h.v = b
i.p = l
i.w = j
i.v = g
assert j.p.w.p.p.p.v.y.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.y: A = None
        self.txt = txt

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

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

b = A("b")
c = B("c")
l = C("l")
f = B("f")
g = A("g")
j = C("j")
h = B("h")
i = B("i")

b.q = g
b.y = g
c.p = j
c.w = j
c.v = g
l.p = i
f.p = j
f.w = j
f.v = b
g.q = b
g.y = b
j.p = i
h.p = j
h.w = l
h.v = b
i.p = l
i.w = j
i.v = g
assert j.p.w.p.p.p.v.y.txt == "b"