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

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

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

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

k = A("k")
d = B("d")
h = C("h")
j = D("j")
e = D("e")
g = B("g")
l = B("l")

k.v = e
k.x = e
d.u = k
h.v = g
h.o = g
h.t = e
j.v = l
e.v = d
g.u = k
l.u = k
assert k.v.v.u.x.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.x: D = None
        self.txt = txt

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

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

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

k = A("k")
d = B("d")
h = C("h")
j = D("j")
e = D("e")
g = B("g")
l = B("l")

k.v = e
k.x = e
d.u = k
h.v = g
h.o = g
h.t = e
j.v = l
e.v = d
g.u = k
l.u = k
assert k.v.v.u.x.v.txt == "d"