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

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

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

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

i = A("i")
n = B("n")
m = C("m")
g = D("g")
b = D("b")
h = B("h")
f = B("f")

i.q = m
i.u = m
n.x = f
n.y = m
m.o = i
g.v = n
g.x = n
g.w = i
b.v = n
b.x = n
b.w = i
h.x = f
h.y = m
f.x = n
f.y = m
assert b.v.x.y.o.q.o.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.u: C = None
        self.txt = txt

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

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

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

i = A("i")
n = B("n")
m = C("m")
g = D("g")
b = D("b")
h = B("h")
f = B("f")

i.q = m
i.u = m
n.x = f
n.y = m
m.o = i
g.v = n
g.x = n
g.w = i
b.v = n
b.x = n
b.w = i
h.x = f
h.y = m
f.x = n
f.y = m
assert b.v.x.y.o.q.o.q.txt == "m"