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

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

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

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

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

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

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

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

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

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

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