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

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

class C:
    def __init__(self, txt: str):
        self.x: A = None
        self.q: A = None
        self.t: D = None
        self.u: A = None
        self.txt = txt

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

l = A("l")
m = B("m")
k = C("k")
d = D("d")
g = A("g")
b = A("b")
f = D("f")

l.s = k
m.v = f
k.x = b
k.u = b
k.q = l
k.t = d
d.t = b
g.s = k
b.s = k
f.t = b
assert m.v.t.s.t.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.x: A = None
        self.q: A = None
        self.t: D = None
        self.u: A = None
        self.txt = txt

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

l = A("l")
m = B("m")
k = C("k")
d = D("d")
g = A("g")
b = A("b")
f = D("f")

l.s = k
m.v = f
k.x = b
k.u = b
k.q = l
k.t = d
d.t = b
g.s = k
b.s = k
f.t = b
assert m.v.t.s.t.txt == "d"