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

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

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

l = A("l")
a = B("a")
m = C("m")
d = C("d")
g = A("g")
c = A("c")
j = A("j")
f = B("f")
b = C("b")

l.s = a
l.q = d
l.x = f
a.y = d
a.r = m
m.u = c
m.p = j
d.u = c
d.p = c
g.s = f
g.x = f
g.q = b
c.s = f
c.x = f
c.q = d
j.s = f
j.q = d
j.x = a
f.y = b
f.r = d
b.u = g
b.p = g
assert m.u.x.y.p.x.y.u.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.q: C = None
        self.x: B = None
        self.txt = txt

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

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

l = A("l")
a = B("a")
m = C("m")
d = C("d")
g = A("g")
c = A("c")
j = A("j")
f = B("f")
b = C("b")

l.s = a
l.q = d
l.x = f
a.y = d
a.r = m
m.u = c
m.p = j
d.u = c
d.p = c
g.s = f
g.x = f
g.q = b
c.s = f
c.x = f
c.q = d
j.s = f
j.q = d
j.x = a
f.y = b
f.r = d
b.u = g
b.p = g
assert m.u.x.y.p.x.y.u.txt == "g"