class A:
    def __init__(self, txt: str):
        self.q: B = 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.u: A = None
        self.txt = txt

k = A("k")
m = B("m")
f = C("f")
n = C("n")
d = A("d")
e = A("e")
c = C("c")

k.q = m
m.y = e
f.u = d
n.u = d
d.q = m
e.q = m
c.u = k
assert c.u.q.y.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = 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.u: A = None
        self.txt = txt

k = A("k")
m = B("m")
f = C("f")
n = C("n")
d = A("d")
e = A("e")
c = C("c")

k.q = m
m.y = e
f.u = d
n.u = d
d.q = m
e.q = m
c.u = k
assert c.u.q.y.q.txt == "m"