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

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

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

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

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

d = A("d")
m = B("m")
k = C("k")
n = D("n")
g = E("g")
b = B("b")

d.s = n
m.v = d
m.t = d
k.t = n
k.u = g
n.v = k
g.u = n
b.v = d
b.t = d
assert m.t.s.v.txt == "
class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.txt = txt

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

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

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

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

d = A("d")
m = B("m")
k = C("k")
n = D("n")
g = E("g")
b = B("b")

d.s = n
m.v = d
m.t = d
k.t = n
k.u = g
n.v = k
g.u = n
b.v = d
b.t = d
assert m.t.s.v.txt == "k"