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

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

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

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

l.q = k
l.p = f
n.y = l
c.q = n
k.y = f
f.q = n
f.p = j
h.y = j
j.q = n
j.p = l
g.q = n
b.q = k
d.q = n
assert d.q.y.p.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.p: A = None
        self.txt = txt

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

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

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

l.q = k
l.p = f
n.y = l
c.q = n
k.y = f
f.q = n
f.p = j
h.y = j
j.q = n
j.p = l
g.q = n
b.q = k
d.q = n
assert d.q.y.p.q.txt == "n"