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

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

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

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

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

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

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

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

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