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

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

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

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

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

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

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

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

l.x = d
m.q = a
m.r = l
m.s = d
f.q = b
h.x = j
e.x = m
j.q = h
j.r = c
j.s = m
c.x = j
a.x = m
d.q = h
d.r = h
d.s = j
b.q = f
assert h.x.r.x.s.q.x.r.txt == "l"