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

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

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

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

m = A("m")
f = B("f")
l = C("l")
h = D("h")
g = A("g")

m.q = f
m.u = g
m.r = l
m.s = h
f.x = l
f.z = m
l.v = h
l.z = f
l.x = f
l.q = m
h.z = g
h.s = f
g.q = f
g.u = m
g.r = l
g.s = h
assert g.s.s.x.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.u: A = None
        self.r: C = None
        self.s: D = None
        self.txt = txt

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

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

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

m = A("m")
f = B("f")
l = C("l")
h = D("h")
g = A("g")

m.q = f
m.u = g
m.r = l
m.s = h
f.x = l
f.z = m
l.v = h
l.z = f
l.x = f
l.q = m
h.z = g
h.s = f
g.q = f
g.u = m
g.r = l
g.s = h
assert g.s.s.x.txt == "l"