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

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

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

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

i = A("i")
j = B("j")
c = C("c")
g = D("g")
n = C("n")

i.p = g
i.w = g
i.q = c
i.r = j
j.w = i
j.o = i
j.v = g
c.w = i
c.r = i
c.u = g
c.x = g
g.u = c
g.r = n
g.x = j
n.w = i
n.r = i
n.u = g
n.x = g
assert j.v.r.u.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.q: C = None
        self.r: B = None
        self.w: D = None
        self.txt = txt

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

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

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

i = A("i")
j = B("j")
c = C("c")
g = D("g")
n = C("n")

i.p = g
i.w = g
i.q = c
i.r = j
j.w = i
j.o = i
j.v = g
c.w = i
c.r = i
c.u = g
c.x = g
g.u = c
g.r = n
g.x = j
n.w = i
n.r = i
n.u = g
n.x = g
assert j.v.r.u.txt == "g"