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

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

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

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

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

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

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

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

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

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

m.w = h
m.v = h
m.r = g
g.p = j
l.r = f
l.p = f
l.x = h
f.t = g
f.p = g
f.r = g
b.r = f
b.p = f
b.x = m
h.w = m
h.v = m
h.r = g
j.r = f
j.p = f
j.x = h
assert l.x.w.r.txt == "g"