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

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

class C:
    def __init__(self, txt: str):
        self.y: B = None
        self.w: A = None
        self.o: B = None
        self.txt = txt

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

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

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

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

class C:
    def __init__(self, txt: str):
        self.y: B = None
        self.w: A = None
        self.o: B = None
        self.txt = txt

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

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

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