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

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

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

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

c.r = g
c.t = g
c.z = l
h.w = f
h.o = f
l.p = h
l.q = f
g.r = c
g.t = c
g.z = j
f.w = h
f.o = h
j.p = h
j.q = h
b.p = f
b.q = h
assert l.q.w.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.z: C = None
        self.t: A = None
        self.txt = txt

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

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

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

c.r = g
c.t = g
c.z = l
h.w = f
h.o = f
l.p = h
l.q = f
g.r = c
g.t = c
g.z = j
f.w = h
f.o = h
j.p = h
j.q = h
b.p = f
b.q = h
assert l.q.w.o.o.txt == "h"