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

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

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

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

d = A("d")
j = B("j")
f = C("f")
i = D("i")
k = C("k")
h = A("h")
c = A("c")
m = C("m")
g = A("g")

d.q = i
d.s = i
j.u = i
j.v = f
f.x = j
f.t = i
i.r = c
i.v = j
i.x = j
k.x = j
k.t = i
h.q = i
h.s = i
c.q = i
c.s = i
m.x = j
m.t = i
g.q = i
g.s = i
assert j.v.x.v.x.txt == "
class A:
    def __init__(self, txt: str):
        self.q: D = None
        self.s: D = None
        self.txt = txt

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

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

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

d = A("d")
j = B("j")
f = C("f")
i = D("i")
k = C("k")
h = A("h")
c = A("c")
m = C("m")
g = A("g")

d.q = i
d.s = i
j.u = i
j.v = f
f.x = j
f.t = i
i.r = c
i.v = j
i.x = j
k.x = j
k.t = i
h.q = i
h.s = i
c.q = i
c.s = i
m.x = j
m.t = i
g.q = i
g.s = i
assert j.v.x.v.x.txt == "j"