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

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

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

f = A("f")
a = B("a")
j = C("j")
c = A("c")
l = A("l")

f.y = c
f.q = l
a.u = l
j.p = c
j.x = l
c.y = f
c.q = f
l.y = f
l.q = f
assert j.p.q.y.y.q.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.q: A = None
        self.txt = txt

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

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

f = A("f")
a = B("a")
j = C("j")
c = A("c")
l = A("l")

f.y = c
f.q = l
a.u = l
j.p = c
j.x = l
c.y = f
c.q = f
l.y = f
l.q = f
assert j.p.q.y.y.q.txt == "l"