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

class D:
    def __init__(self, txt: str):
        self.y: C = None
        self.t: D = None
        self.p: C = None
        self.x: D = None
        self.txt = txt

l = A("l")
n = B("n")
i = C("i")
b = D("b")
g = D("g")

l.s = n
n.x = g
i.u = l
i.p = l
i.q = n
b.y = i
b.p = i
b.t = g
b.x = g
g.y = i
g.p = i
g.t = b
g.x = b
assert l.s.x.y.q.x.txt == "
class A:
    def __init__(self, txt: str):
        self.s: 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.u: A = None
        self.p: A = None
        self.q: B = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.y: C = None
        self.t: D = None
        self.p: C = None
        self.x: D = None
        self.txt = txt

l = A("l")
n = B("n")
i = C("i")
b = D("b")
g = D("g")

l.s = n
n.x = g
i.u = l
i.p = l
i.q = n
b.y = i
b.p = i
b.t = g
b.x = g
g.y = i
g.p = i
g.t = b
g.x = b
assert l.s.x.y.q.x.txt == "g"