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

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

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

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

class E:
    def __init__(self, txt: str):
        self.x: E = None
        self.v: F = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.w: D = None
        self.txt = txt

b = A("b")
f = B("f")
c = C("c")
g = D("g")
h = E("h")
a = F("a")
e = C("e")
i = C("i")
j = E("j")

b.o = e
f.z = a
f.w = b
c.o = a
c.r = g
g.t = b
h.x = j
h.v = a
a.w = g
e.o = a
e.r = g
i.o = a
i.r = g
j.x = h
j.v = a
assert j.v.w.t.o.r.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.x: E = None
        self.v: F = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.w: D = None
        self.txt = txt

b = A("b")
f = B("f")
c = C("c")
g = D("g")
h = E("h")
a = F("a")
e = C("e")
i = C("i")
j = E("j")

b.o = e
f.z = a
f.w = b
c.o = a
c.r = g
g.t = b
h.x = j
h.v = a
a.w = g
e.o = a
e.r = g
i.o = a
i.r = g
j.x = h
j.v = a
assert j.v.w.t.o.r.txt == "g"