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

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

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

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

f = A("f")
e = B("e")
c = C("c")
n = D("n")
g = B("g")
a = C("a")
l = B("l")
j = D("j")
b = A("b")
d = C("d")

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

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

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

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

f = A("f")
e = B("e")
c = C("c")
n = D("n")
g = B("g")
a = C("a")
l = B("l")
j = D("j")
b = A("b")
d = C("d")

f.s = j
f.q = l
e.x = n
c.x = d
n.q = j
g.x = n
a.x = c
l.x = n
j.q = n
b.s = j
b.q = l
d.x = c
assert l.x.q.q.q.q.q.q.q.txt == "j"