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

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

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

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

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

g.y = m
m.y = f
m.q = c
l.q = h
l.w = h
l.u = g
h.p = f
h.w = f
h.o = c
h.v = l
f.q = h
f.w = h
f.u = g
c.y = f
c.q = m
assert c.y.w.v.u.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

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

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

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

g.y = m
m.y = f
m.q = c
l.q = h
l.w = h
l.u = g
h.p = f
h.w = f
h.o = c
h.v = l
f.q = h
f.w = h
f.u = g
c.y = f
c.q = m
assert c.y.w.v.u.txt == "g"