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

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

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

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

f = A("f")
j = B("j")
a = C("a")
c = D("c")
g = A("g")
h = B("h")
m = C("m")
i = C("i")

f.v = c
f.x = a
f.t = g
j.t = h
j.v = h
j.p = c
a.r = c
a.v = c
a.x = f
a.t = m
c.u = a
c.p = i
g.v = c
g.x = m
g.t = f
h.t = j
h.v = j
h.p = c
m.r = c
m.v = c
m.x = g
m.t = i
i.r = c
i.v = c
i.x = f
i.t = a
assert m.x.x.r.p.txt == "
class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.x: C = None
        self.t: A = None
        self.txt = txt

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

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

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

f = A("f")
j = B("j")
a = C("a")
c = D("c")
g = A("g")
h = B("h")
m = C("m")
i = C("i")

f.v = c
f.x = a
f.t = g
j.t = h
j.v = h
j.p = c
a.r = c
a.v = c
a.x = f
a.t = m
c.u = a
c.p = i
g.v = c
g.x = m
g.t = f
h.t = j
h.v = j
h.p = c
m.r = c
m.v = c
m.x = g
m.t = i
i.r = c
i.v = c
i.x = f
i.t = a
assert m.x.x.r.p.txt == "i"