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

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

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

class D:
    def __init__(self, txt: str):
        self.x: A = None
        self.q: D = None
        self.t: A = None
        self.txt = txt

j = A("j")
e = B("e")
d = C("d")
h = D("h")
b = C("b")
i = C("i")
l = C("l")
m = B("m")
g = D("g")

j.v = d
e.q = j
e.p = m
e.w = g
d.r = g
h.x = j
h.t = j
h.q = g
b.r = h
i.r = g
l.r = g
m.q = j
m.p = e
m.w = h
g.x = j
g.t = j
g.q = h
assert b.r.q.x.v.r.q.x.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.x: A = None
        self.q: D = None
        self.t: A = None
        self.txt = txt

j = A("j")
e = B("e")
d = C("d")
h = D("h")
b = C("b")
i = C("i")
l = C("l")
m = B("m")
g = D("g")

j.v = d
e.q = j
e.p = m
e.w = g
d.r = g
h.x = j
h.t = j
h.q = g
b.r = h
i.r = g
l.r = g
m.q = j
m.p = e
m.w = h
g.x = j
g.t = j
g.q = h
assert b.r.q.x.v.r.q.x.txt == "j"