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

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

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

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

d = A("d")
a = B("a")
f = C("f")
h = D("h")
b = D("b")
j = B("j")
k = A("k")
c = B("c")
g = B("g")

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

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

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

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

d = A("d")
a = B("a")
f = C("f")
h = D("h")
b = D("b")
j = B("j")
k = A("k")
c = B("c")
g = B("g")

d.x = b
d.u = b
d.s = k
a.s = d
a.v = j
f.o = b
h.u = f
h.t = f
h.q = c
b.u = f
b.t = f
b.q = j
j.s = k
j.v = g
k.x = h
k.s = d
k.u = b
c.s = k
c.v = g
g.s = d
g.v = c
assert f.o.u.o.q.s.u.q.s.s.txt == "d"