class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.p: C = None
        self.r: D = None
        self.y: B = None
        self.txt = txt

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

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

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

b = A("b")
g = B("g")
m = C("m")
j = D("j")
n = D("n")
a = A("a")
f = D("f")

b.o = m
b.p = m
b.r = f
b.y = g
g.r = b
m.w = g
m.v = n
j.r = g
j.q = g
j.t = m
n.r = g
n.q = g
n.t = m
a.o = m
a.p = m
a.r = j
a.y = g
f.r = g
f.q = g
f.t = m
assert f.t.v.r.r.o.w.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.p: C = None
        self.r: D = None
        self.y: B = None
        self.txt = txt

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

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

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

b = A("b")
g = B("g")
m = C("m")
j = D("j")
n = D("n")
a = A("a")
f = D("f")

b.o = m
b.p = m
b.r = f
b.y = g
g.r = b
m.w = g
m.v = n
j.r = g
j.q = g
j.t = m
n.r = g
n.q = g
n.t = m
a.o = m
a.p = m
a.r = j
a.y = g
f.r = g
f.q = g
f.t = m
assert f.t.v.r.r.o.w.txt == "g"