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

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

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

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

l = A("l")
e = B("e")
b = C("b")
d = D("d")
m = B("m")
a = C("a")
g = B("g")
i = C("i")
c = A("c")

l.u = i
l.v = i
e.u = c
e.r = c
e.y = g
e.s = l
b.x = m
b.z = d
d.z = c
d.x = l
m.u = l
m.r = l
m.y = g
m.s = c
a.x = m
a.z = d
g.u = c
g.s = c
g.r = l
g.y = m
i.x = e
i.z = d
c.u = a
c.v = b
assert g.u.v.x.s.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.v: C = None
        self.txt = txt

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

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

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

l = A("l")
e = B("e")
b = C("b")
d = D("d")
m = B("m")
a = C("a")
g = B("g")
i = C("i")
c = A("c")

l.u = i
l.v = i
e.u = c
e.r = c
e.y = g
e.s = l
b.x = m
b.z = d
d.z = c
d.x = l
m.u = l
m.r = l
m.y = g
m.s = c
a.x = m
a.z = d
g.u = c
g.s = c
g.r = l
g.y = m
i.x = e
i.z = d
c.u = a
c.v = b
assert g.u.v.x.s.txt == "c"