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

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

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

l = A("l")
g = B("g")
c = C("c")
m = B("m")
e = A("e")
a = C("a")
k = C("k")

l.y = m
g.q = c
g.s = c
g.x = m
c.v = k
c.r = e
c.p = m
m.q = a
m.x = g
m.s = c
e.y = g
a.v = k
a.r = e
a.p = m
k.v = c
k.r = e
k.p = m
assert a.p.x.s.r.y.s.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

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

l = A("l")
g = B("g")
c = C("c")
m = B("m")
e = A("e")
a = C("a")
k = C("k")

l.y = m
g.q = c
g.s = c
g.x = m
c.v = k
c.r = e
c.p = m
m.q = a
m.x = g
m.s = c
e.y = g
a.v = k
a.r = e
a.p = m
k.v = c
k.r = e
k.p = m
assert a.p.x.s.r.y.s.txt == "c"