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

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

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

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

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

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

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

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

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

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

g.x = c
g.v = k
c.s = k
c.o = b
k.u = m
k.w = f
k.r = b
k.v = b
i.y = j
i.t = m
b.x = c
b.v = j
j.u = m
j.w = k
j.r = g
j.v = b
f.u = m
f.w = k
f.r = g
f.v = b
m.y = f
m.t = i
assert g.v.w.r.txt == "g"